package com.caipiao.lottery.lty.message;

/**
 * @author GaoFeng
 */

import com.alibaba.fastjson.annotation.JSONField;
import com.caipiao.lottery.cache.SessionData;
import com.caipiao.util.StringTools;

public class LtyRequest extends MessageRequest
{
	public String msgId = "";					//消息流水
	public String deviceId = "";				//设备号
	public String keyId = "";					//密钥编号
	public String session = "";				//会话
	public String mode = "";					//数据模式
	public String body = "";					//数据体
	public String digest = "";					//摘要	
	
	@JSONField(serialize=false)
	public MessageRequest bodyMsg = null;		//包体结构
	
	@JSONField(serialize=false)
	public SessionData sessionData = null;		//会话数据
	
	@JSONField(serialize=false)
	public String productId = "";
	
	@JSONField(serialize=false)
	public String channelId = "";
	
	@JSONField(serialize=false)
	public String version = "";
	
	@JSONField(serialize=false)
	public String cmd = "";
	
	@Override
	public void CheckParam() throws Exception
	{
		if (null == this.mode || this.mode.isEmpty())
		{
			this.mode = "1";
		}
		
		if (!this.body.isEmpty())
		{
			String check_digest = StringTools.MD5EncodeToHex(this.body);
			if (!check_digest.equalsIgnoreCase(this.digest))
			{
				throw new Exception("digest不一致,ori:" + this.digest
						+ "|check:" + check_digest);
			}
		}
	}
}
